<template>
  <div class="recommend">
    <el-row>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          <h2>今日推荐</h2>
        </div>
      </el-col>
      <el-col :span="17">
        <div class="grid-content bg-purple">
          <ul id="tuijian">
            <router-link
              tag="li"
              :to="{name:'Menu',params:{id:menus.name}}"
              v-for="menus in menusList"
              :key="menus.id"
            >{{menus.name}}</router-link>
          </ul>
        </div>
      </el-col>
      <el-col :span="3">
        <div class="grid-content bg-purple">
          <span>
            <router-link to="/menu" class="all">查看全部 ></router-link>
          </span>
        </div>
      </el-col>
    </el-row>
    <div class="tuipic">
      <router-link
        tag="li"
        v-for="(todaydata,index) in todayMenusList"
        v-show="index<4"
        :key="todaydata.menuId"
        :to="{ name: 'menuchild', params: { id: todaydata.menuId } }"
      >
        <span class="menuId">{{todaydata.menuId}}</span>
        <div class="img_5">
          <img :src="'/api/upload/' + todaydata.menuBigImg" alt />
        </div>
        <p>
          <span class="menuming">{{todaydata.menuName}}</span>
          <br />
          <span>{{todaydata.fansNum}}</span>粉丝
        </p>
      </router-link>
    </div>
  </div>
</template>
<style lang="css" scoped>
li {
  list-style: none;
}
.el-row {
  margin-bottom: 10px;
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 48px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

h2 {
  font-size: 20px;
  color: #E6A23C;
  font-weight: 700;
  line-height: 48px;
  margin-left: 15px;
}
#tuijian {
  list-style: none;
}
#tuijian li {
  display: inline-block;
  width: 90px;
  height: 35px;
  text-align: center;
  line-height: 35px;
  border: 1px solid #eee;
  background-color: #eee;
  border-radius: 25px;
  cursor: pointer;
  font-size: 18px;
  margin-right: 30px;
  margin-top: 6px;
}
#tuijian li:hover {
  background-color: #E6A23C;
  color: white;
  border: 1px solid #E6A23C;
}
.img_5{
  width: 90%;
  border-radius: 5px;
  overflow: hidden;
  height: 300px;
  display: inline-block;
}
.tuipic img {
  cursor: pointer;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* object-position: center; */
  border-radius: 5px;
}
.img_5:hover {
  border-radius: 5px;
  box-shadow: 5px 5px 5px 4px #ccc;
}
.tuipic p {
  margin-top: 5px;
  margin-left: 15px;
  line-height: 1.5em;
  width: 90%;
  text-align: left;
}
.tuipic p .menuming {
  display: inline-block;
  width: 100%;
  color: black;
  height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}
.tuipic p .menuming:hover {
  color: #E6A23C;
  cursor: pointer;
}
.tuipic span {
  color: rgb(170, 170, 170);
}
.tuipic li {
  text-align: center;
  list-style: none;
  float: left;
  margin-top: 10px;
  width: 25%;
}
.all {
  text-decoration: none;
  color: black;
  font-size: 18px;
  line-height: 48px;
  float: right;
}
.all:hover {
  color: #E6A23C;
}
.menuId {
  display: none;
}

</style>
<script>
export default {
  data() {
    return {
      menusList: [
        { id: 1, name: "口水鸡" },
        { id: 2, name: "小龙虾" },
        { id: 3, name: "水煮鱼" },
        { id: 4, name: "冰粉" },
        { id: 5, name: "辣子鸡" }
      ],
      todayMenusList: []
    };
  },
  //钩子函数
  created() {
    this.$axios
      .get("/api/createMenu/getDataMenu")
      .then(res => {
        this.todayMenusList = res.data.data;
        // console.log("todayMenusList:", this.todayMenusList);
      })
      .catch(err => {
        console.log("err:", err);
      });
    }
};
</script>